
ntctotemp ={}

ntcData = {329500, ---50
310900, 293500, 277200, 262000, 247700, 234300, 221700, 209900, 198900, 188500, 178500, 169000, 160200, 151900, 144100,
           136700, 129800, 123300, 117100, 111300, 105700, 100500, 95520, 90840, 86430, 82260, 78330, 74610, 71100,
           67770, 64570, 61540, 58680, 55970, 53410, 50980, 48680, 46500, 44430, 42470, 40570, 38770, 37060, 35440,
           33900, 32440, 31050, 29730, 28480, 27280, 26130, 25030, 23990, 23000, 22050, 21150, 20300, 19480, 18700,
           17960, 17240, 16560, 15900, 15280, 14690, 14120, 13580, 13060, 12560, 12090, 11630, 11200, 10780, 10380,
           10000, 9632, 9281, 8944, 8622, 8313, 8014, 7728, 7454, 7192, 6940, 6699, 6467, 6245, 6032, 5827, 5629, 5438,
           5255, 5080, 4911, 4749, 4593, 4443, 4299, 4160, 4026, 3896, 3771, 3651, 3536, 3425, 3318, 3215, 3116, 3020,
           2927, 2838, 2751, 2668, 2588, 2511, 2436, 2364, 2295, 2228, 2163, 2100, 2039, 1980, 1924, 1869, 1816, 1765,
           1716, 1668, 1622, 1577, 1533, 1492, 1451, 1412, 1373, 1336, 1301, 1266, 1232, 1200, 1168, 1137, 1108, 1079,
           1051, 1024, 998, 973, 948, 924, 901, 878, 857, 836, 815, 795, 776, 757 -- 110
};
function ntctotemp.temp(PT_R)
    if PT_R==nil then
        return nil
    end
    for i = 0, 161 do
        if PT_R > ntcData[i] then
            break
        end
    end
    if i == 0 then
        tp = -500
    end
    if i >= 161 then
        tp = 1100
    else
        tp = (PT_R - ntcData[i - 1]) * 10 / (ntcData[i] - ntcData[i - 1]) + (i - 50 - 1) * 10;
    end
    return tp;
end